@extends('manage.layout')

@section('content')
    <section class="content-header">
        <h1>
            添加行业
            <small>Preview</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="#">Case</a></li>
            <li class="active">Case Industry Edit</li>
        </ol>
    </section>

    <section class="content">
        <div class="row">
            <!-- left column -->
            <div class="col-md-12">
                <!-- general form elements -->
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title">内容</h3>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <form action="{{ url('case/industryUpdate') }}" method="post" role="form" style="width: 50%;">
                        {{csrf_field()}}
                        <div class="box-body">
                            <input type="hidden" name="id" value="{{ $industry->id }}">
                            <div class="form-group">
                                <label for="exampleInputPassword1">权重</label>
                                <input type="number" name="rank" min="0" value="{{ $industry->rank }}" class="form-control" placeholder="Industry rank">
                            </div>
                            <div class="form-group">
                                <label for="exampleInputPassword1">行业名称</label>
                                <input type="text" name="name" class="form-control" id="exampleInputPassword1" value="{{ $industry->name }}" placeholder="Industry Name">
                            </div>
                        </div>
                        <!-- /.box-body -->

                        <div class="box-footer">
                            <button type="submit" class="btn btn-primary">Submit</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>
@stop

@section('script')
    <script>
        $(function() {
            $("form").submit(function(event) {
                event.preventDefault();
                var url = $(this).attr("action");
                $.ajaxSetup({
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    }
                });
                $.ajax({
                    url: url,
                    type: "POST",
                    data: $("form").serialize(),
                    dataType: "json",
                    success: function(data) {
                        console.log(data);
                        if(data.code == 100) {
                            window.location.href = "/case/industryList";
                            layer.msg(data.msg)
                        }
                        else {
                            layer.msg(data.msg)
                        }
                    }
                });
            });
        });
    </script>

@stop